<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>欢迎</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
        <script src="https://unpkg.com/vue/dist/vue.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <style type="text/css">
            .welcome {
                width: 500px;
                height: 200px;
                display: flex;
                flex-direction: column;
                justify-content: space-around;
                align-items: center;
                margin: 0 auto;
            }

            .logoutButton {
                background-color: lightpink;
            }
        </style>
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
        <div id="app" class="welcome">
            {{ email }} 欢迎登陆系统!
            <button class="logoutButton" @click="logout()">登出</button>
        </div>
        
        <script type="text/javascript">
        
            new Vue({
                el: '#app',
                data: {
                    email: ''
                },
                mounted() {
                    var that = this;
                    axios.get('http://localhost:80/api/user/info')
                        .then(function(response){
                            console.log(response.data);
                            that.email = response.data;
                            console.log(that.email);
                        })
                        .catch(function(error){
                            console.log(error);
                        });
                },
                methods: {
                    logout() {
                        var formData = new FormData();
                        formData.append('email', this.email);
                        axios.post('http://localhost:80/api/user/logout', formData)
                        .then(function(response){
                            //console.log(response);
                            window.location.href='login.html';
                        })
                        .catch(function(error){
                            console.log(error);
                        });
                    }
                }
            })

        </script>
    </body>
</html>